package com.jd.risk.bankorder.controller.bankorder;

import com.jd.risk.bankorder.common.CommonResult;
import com.jd.risk.bankorder.controller.BaseController;
import com.jd.risk.bankorder.entity.bankorder.TeslaBankRequest;
import com.jd.risk.bankorder.service.bankorder.BankOrderReplyService;
import com.jd.risk.bankorder.service.bankorder.BankOrderService;
import com.jd.risk.bankorder.util.CommonUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/bank/cardOrderRequest")
public class CardOrderRequestController extends BankOrderRequestController{

	@Autowired
	private BankOrderService bankOrderService;

	@Autowired
	private BankOrderReplyService bankOrderReplyService;

	@RequestMapping("/toBankOrderListRequestPage")
	public String toBankOrderList(ModelMap map)
	{
		map.put("bankRequestType","1");
		return "bankorder/bankOrderRequestList";
	}

	@RequestMapping("/toAddBankOrderRequestPage")
	public String toAddBankOrderRequestPage(ModelMap map ){
		map.put("bankRequestType","1");
		return  "bankorder/addBankOrderRequestPage";
	}

	@RequestMapping("/toBatchBankOrderRequestPage")
	public String toBatchBankOrderRequestPage(ModelMap map)
	{
		map.put("bankRequestType","1");
		return "bankorder/batchBankOrderRequestPage";
	}

	@ResponseBody
	@RequestMapping("/batchBankOrderRequest")
	public String batchBankOrderRequest(@RequestParam MultipartFile uploadObject)
	{
		Map<String,Object> result = new HashMap<String, Object>();
		try {
			InputStream inputStream = uploadObject.getInputStream();
			String content = uploadObject.getContentType();
			String orgiginalFileName = uploadObject.getOriginalFilename();
			bankOrderService.batchBankOrderRequest(inputStream ,orgiginalFileName,"1" );
		} catch (IOException e) {
			e.printStackTrace();
		}
		result.put("success",true);
		return toJson(result);
	}



}